package com.xiaotu.principle.inversion.improve;

/**
 * @author 张晓
 * @create 2020-06-17 17:17
 */
public class DependencyInversion {

    public static void main(String[] args) {
        Person person = new Person();
        person.receive(new Email());
        person.receive(new WeiXin());
    }

}

//定义接口
interface IReceiver{
    String getInfo();
}

class Email implements IReceiver{
    public String getInfo(){
        return "电子邮件信息：hello,world";
    }
}

class WeiXin implements IReceiver{

    @Override
    public String getInfo() {
        return "微信信息：hello,ok";
    }
}



//方式2
class Person{
    //这里是我们对接口的依赖
    public void receive(IReceiver iReceiver){
        System.out.println(iReceiver.getInfo());
    }
}

